package fts.ftsdata.domain.impl;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import fts.ftsdata.domain.IWatchFolder;
import fts.ftsdata.domain.IWatchWildcard;


public class WatchFolder implements IWatchFolder
{
	private int idWatchFolder;
	private String path;
	private Set<WatchWildcard> wildcards;
	


	
	Set<WatchWildcard> getWildcards()
	{
		return wildcards;
	}

	
	void setWildcards(Set<WatchWildcard> wildcards)
	{
		this.wildcards = wildcards;
	}

	public Iterator<WatchWildcard> getWildcardsIterator()
	{
		// TODO Auto-generated method stub
		return wildcards.iterator();
	}

	public void addWildcard(IWatchWildcard wildcard)
	{
		System.out.println(Thread.currentThread().getStackTrace()[1]);

		if(wildcards == null)
		{
			wildcards = new HashSet<WatchWildcard>();
		}
		if(!wildcards.contains(wildcard))
		{
			wildcards.add((WatchWildcard) wildcard);
		}
	}

	public void removeWildcard(IWatchWildcard wildcard)
	{
		System.out.println(Thread.currentThread().getStackTrace()[1]);

		if(wildcards.contains(wildcard))
		{
			wildcards.remove((WatchWildcard) wildcard);
		}
	}


	public void setPath(String path)
	{
		this.path = path;
	}



	public String getPath()
	{
		return path;
	}



	public void setIdWatchFolder(int idWatchFolder)
	{
		this.idWatchFolder = idWatchFolder;
	}



	public int getIdWatchFolder()
	{
		return idWatchFolder;
	}



	public void setTags(Set<WatchWildcard> wildcards)
	{
		this.wildcards = wildcards;
	}



	public Set<WatchWildcard> getTags()
	{
		return wildcards;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((path == null) ? 0 : path.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		WatchFolder other = (WatchFolder) obj;
		if (path == null)
		{
			if (other.path != null)
				return false;
		}
		else if (!path.equals(other.path))
			return false;
		return true;
	}

	
}
